package com.cn.sku.service.imp;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cn.sku.SkuGood;
import com.cn.sku.dao.SkuGoodDao;
import com.cn.sku.service.SkuGoodService;
import com.cn.utils.PageUtils;
import com.cn.utils.Query;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class SkuGoodImpService extends ServiceImpl<SkuGoodDao, SkuGood> implements SkuGoodService {
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<SkuGood> page = this.page(
                new Query<SkuGood>().getPage(params),
                new QueryWrapper<>()
        );
        return new PageUtils(page);
    }

    @Override
    public List<SkuGood> getSkuGoodList(String categoryId) {
        QueryWrapper<SkuGood> queryWrapper = (QueryWrapper<SkuGood>) new QueryWrapper().eq("category_id", categoryId);
        return this.list(queryWrapper);
    }
}
